import javax.rmi.ssl.SslRMIClientSocketFactory;

/*
 * @lc app=leetcode.cn id=299 lang=java
 *
 * [299] 猜数字游戏
 */

// @lc code=start
class Solution {
    public String getHint(String secret, String guess) {
        int n = secret.length();
        char[] s1 = secret.toCharArray();
        char[] s2 = guess.toCharArray();
        int a = 0, b = 0;
        int[] cnt1 = new int[10], cnt2 = new int[10];
        for(int i = 0; i < n; i++){
            if(s1[i] == s2[i]){
                a++;
            }
            else{
                cnt1[s1[i] - '0']++;
                cnt2[s2[i] - '0']++;
            }
        }
        for(int i = 0; i < 10; i++){
            b += Math.min(cnt1[i], cnt2[i]);
        }
        return a + "A" + b +"B";
    }
}
// @lc code=end

